from pydantic import BaseSettings, AnyHttpUrl, IPvAnyAddress
from typing import Union
from urllib.parse import quote_plus


class Config(BaseSettings):

    ALGORITHM = "HS256"

    ACCESS_TOKEN_EXPIRE_MINUTES: int = 120
    REFRESH_TOKEN_EXPIRE_MINUTES: int = 1

    SECRET_KEY: str = "bd5ab949af96ed73b7033f7b38ea13f618b07ae1d724121f085ceffde2affec4"

    # 配置你的Mysql环境
    MYSQL_USERNAME: str = 'eiqc_db_user'
    MYSQL_PASSWORD: str = "Shikeyi627_163.com"
    MYSQL_HOST: Union[AnyHttpUrl, IPvAnyAddress] = "127.0.0.1"
    MYSQL_PORT: str = '3306'
    MYSQL_DATABASE: str = 'eiqc_db'

    # Mysql地址
    # SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USERNAME}:{quote_plus(MYSQL_PASSWORD)}@" \
    #                           f"{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}"
    SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@" \
                              f"{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}"


config = Config()
